package com.dream.model.order;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;

import com.dream.model.base.AppModelBase;
import com.dream.model.master.Product;

@Entity
@Table(name="t_ord_customer_pro")
public class OrderCustomerProduct extends AppModelBase implements Serializable {



	/**
	 * 
	 */
	private static final long serialVersionUID = -4220144891780855369L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private String id ;
	
	@Column(name="customer_id")
	private Long customerId;
	
	@Column(name="product_id")
	private String productId;
	
	@Column(name="purchsae_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date purchaseDate;

	@Column(name="purchsae_price")
	private Float purchasePrice;
	
	@Column(name="recepit_no")
	private String recepitNo;
	
	@Column(name="bar_code")
	private String barCode;
	
	@Column(name="mandatory_no")
	private String mandatoryNo;
	
	@Column(name="sales_shop")
	private String salesShop;	
	
	@Column(name="sales_contact")
	private String salesContact;	
	
	@Column(name="comments")
	private String comments;			
	
	@Column(name="deleted")
	@Type(type = "org.hibernate.type.NumericBooleanType")
	private Boolean deleted = false;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="product_id",updatable=false,insertable=false)
	private Product product;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name="customer_id",updatable=false,insertable=false)
	private OrderCustomer customer;
	
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public OrderCustomer getCustomer() {
		return customer;
	}

	public void setCustomer(OrderCustomer customer) {
		this.customer = customer;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Long getCustomerId() {
		return customerId;
	}

	public void setCustomerId(Long customerId) {
		this.customerId = customerId;
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public Date getPurchaseDate() {
		return purchaseDate;
	}

	public void setPurchaseDate(Date purchaseDate) {
		this.purchaseDate = purchaseDate;
	}

	public Float getPurchasePrice() {
		return purchasePrice;
	}

	public void setPurchasePrice(Float purchasePrice) {
		this.purchasePrice = purchasePrice;
	}

	public String getRecepitNo() {
		return recepitNo;
	}

	public void setRecepitNo(String recepitNo) {
		this.recepitNo = recepitNo;
	}

	public String getBarCode() {
		return barCode;
	}

	public void setBarCode(String barCode) {
		this.barCode = barCode;
	}

	
	public String getMandatoryNo() {
		return mandatoryNo;
	}

	public void setMandatoryNo(String mandatoryNo) {
		this.mandatoryNo = mandatoryNo;
	}
	
	
	public String getSalesShop() {
		return salesShop;
	}

	public void setSalesShop(String salesShop) {
		this.salesShop = salesShop;
	}

	public String getSalesContact() {
		return salesContact;
	}

	public void setSalesContact(String salesContact) {
		this.salesContact = salesContact;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public Boolean getDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OrderCustomerProduct other = (OrderCustomerProduct) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
}
